/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sound;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

/**
 *
 * @author cottonjb
 */
public class ReadURL {

    private String newsFeedUrl = "";
    private StringBuilder sbNewsFeed = new StringBuilder("");

    ReadURL() {
        // constructor
    }

    public StringBuilder readNewsFeed(String newsFeedUrl){
        setNewsFeedUrl(newsFeedUrl);
        readNewsFeed();
        return getSbNewsFeed();
    }

    public void readNewsFeed() {
        try {
            URL oracle = new URL(newsFeedUrl);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(oracle.openStream()));

            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                sbNewsFeed.append(inputLine);
            }
            in.close();
        } catch (Exception e) {
        }
    }

    public void readTest() {
        try {
            URL oracle = new URL("http://www.oracle.com/");
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(oracle.openStream()));

            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                System.out.println(inputLine);
            }
            in.close();
        } catch (Exception e) {
        }
    }

    public String getNewsFeedUrl() {
        return newsFeedUrl;
    }

    public void setNewsFeedUrl(String newsFeedUrl) {
        this.newsFeedUrl = newsFeedUrl;
    }

    public StringBuilder getSbNewsFeed() {
        return sbNewsFeed;
    }

    public void setSbNewsFeed(StringBuilder sbNewsFeed) {
        this.sbNewsFeed = sbNewsFeed;
    }

    public void say(String s) {
        System.out.println(s);
    }
}
